'abuspritecomponent.monkey
Strict
Import abucomponent
Import abu.abuanimation



Class SpriteComponent Extends EntityComponent<ISprite> Implements ISprite

Private
	Field _sprite := New AbuSprite()															'ISprite component
	Field _displaceX:Int[], _displaceY:Int[]
Public
	Method New()
		_sprite._parent = Self
	End
	
	Method CurrentAnimation:String() Property													Return _sprite.CurrentAnimation												End
	Method NextAnimation:String() Property														Return _sprite.NextAnimation												End
	Method LoopCount:Int() Property																Return _sprite.LoopCount													End
	Method AnimationSheet:AbuAnimationSheet() Property											Return _sprite.AnimationSheet												End
	Method AnimationSheet:Void(animationSheet:AbuAnimationSheet) Property						_sprite.AnimationSheet(animationSheet)										End
	Method SetAnimationSheet:Void(path:String, frameWidth:Int, frameHeight:Int)					_sprite.SetAnimationSheet(path, frameWidth, frameHeight)					End
	Method HandleX:Float() Property																Return _sprite.HandleX														End
	Method HandleY:Float() Property																Return _sprite.HandleY														End
	Method SetHandle:Void(x:Float, y:Float)														_sprite.SetHandle(x, y)														End
	Method SetRate:Void(rate:Float)																_sprite.SetRate(rate)														End

	Method AddAnimation:Void(name:String, sequence:Int[], frameDuration:Int, loop:Bool = True, flipX:Bool = False, flipY:Bool = False)										'..
		_sprite.AddAnimation(name, sequence, frameDuration, loop, flipX, flipY)																								End
	Method AddAnimation:Void(name:String, sequence:Int[], frameDuration:Int[], loop:Bool = True, flipX:Bool = False, flipY:Bool = False)									'..
		_sprite.AddAnimation(name, sequence, frameDuration, loop, flipX, flipY)																								End
	Method AddAnimation:Void(name:String, start:Int, sequence:Int[], frameDuration:Int, loop:Bool = True, flipX:Bool = False, flipY:Bool = False)							'..
		_sprite.AddAnimation(name,start,  sequence, frameDuration, loop, flipX, flipY)																						End
	Method AddAnimation:Void(name:String, start:Int, sequence:Int[], frameDuration:Int[], loop:Bool = True, flipX:Bool = False, flipY:Bool = False)							'..
		_sprite.AddAnimation(name, start, sequence, frameDuration, loop, flipX, flipY)																						End
	Method AddAnimation:Void(name:String, subAnimations:String[], loop:Bool = True, flipX:Bool = False, flipY:Bool = False)													'..
		_sprite.AddAnimation(name, subAnimations, loop, flipX, flipY)																										End
	
	Method PlayAnimation:Void(name:String, reset:Bool = True, rate:Float = 1)					_sprite.PlayAnimation(name, reset, rate)									End
	Method QeueAnimation:Void(name:String, reset:Bool = True, rate:Float = 1)					_sprite.QeueAnimation(name, reset, rate)									End
	Method PlayNextAnimation:Void()																_sprite.PlayNextAnimation();												End
	Method OnAnimationLoop:Void(animation:String)												owner.OnAnimationLoop(animation)											End
	Method OnAnimationEnd:Void(animation:String)												owner.OnAnimationEnd(animation)												End
	Method AddOffset:Void(name:String, offsetX:Int[], offsetY:Int[], cumulative:Bool = False)	_sprite.AddOffset(name, offsetX, offsetY, cumulative)						End
	Method AddDisplacement:Void(name:String, displaceX:Int[], displaceY:Int[])					_sprite.AddDisplacement(name, displaceX, displaceY)							End
	Method _Displace:Void(x:Int, y:Int)
		owner.PhysicsComponent.Move(x, y)
	End
	Method Draw:Void(x:Int, y:Int, rotation:Float = 0, scaleX:Float = 1, scaleY:Float = 1)		_sprite.Draw(x, y, rotation, scaleX, scaleY)								End
	'Method DrawFlipped:Void(x:Int, y:Int, flip:Int = FLIP_X, rotation:Float = 0, scaleX:Float = 1, scaleY:Float = 1)														'..
	'	_sprite.DrawFlipped(x, y, flip, r, sX, sY)																															End
End